<!DOCTYPE HTML>
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>showStorage</title>

    </head>
    <body>
        <p>
本例中:
localStore封装本地存储,各浏览器自适应。<br>
ie6,7使用userdata,<br>
8+,ff,safari,google等 使用localStorage暴露统一调用接口<br>
//修改IE8支持原生的JSON对象，自带了JSON.parse与JSON.stringify两个方法。<br>当我使用json2里的Json.stringify方法里IE默认调用了IE8的stringify方法进行了uncode编码<br>
//解决办法：把Json2.js里的JSON改下名称，改成JSON2,这样调用：JSON2.stringify();(直接替换JSON=>JSON2)<br>
        </p>
		<button onclick="javascript:get('team')">
           localStore.getItem()
        </button> 
			<button onclick="javascript:remove('team')">
           localStore.removeItem()
        </button>
		<button onclick='javascript:save("team","国际米兰")'>
         	localStore.setItem()
        </button>
		<button onclick='javascript:save2()'>
         	save2()
        </button>
        <br>
        <div id="log">
        </div>
    </body>
	   <script type="text/javascript" src="http://127.0.0.1:8080/monitor/js/localstore.js"> </script>
	   <script type="text/javascript" src="http://127.0.0.1:8080/monitor/js/json2.js"> </script>

	<script type="text/javascript">
    var console = {
        log: function(string){
            var logItem = document.getElementById("log");
            var temp = logItem.innerHTML;
            logItem.innerHTML = temp + "<br>" + string;
            
        }
    }
	function get(key){
		console.log("得到key:"+key+","+localStore.getItem(key));
	}
	
	function remove(key){
		localStore.removeItem(key);
		console.log("删除key:"+key);
	}
	
	function save(key,value){
		localStore.setItem(key,value);
		console.log("保存key:"+key);
	}
	
	function save2(){
		var jsonObj = {data:[{
                name: '东 京',
                data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
            }, {
                name: '纽 约',
                data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]
            }, {
                name: '柏 林',
                data: [-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0]
            }, {
                name: '伦 敦',
                data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
            }, {
                name: '北 京',
                data: [13.9, 24.2, 25.7, 18.5, 21.9, 5.2, 7.0, 6.6, 24.2, 13.3, 16.6, 24.8]
            }]
			};
//		alert(jsonObj.data[1].name);
		var value = JSON2.stringify(jsonObj);
//		alert(value);
//		console.log(JSON2.parse(value).data[2].name);
		localStore.setItem("team",value);
//		localStore.setItem("team",'{"team":"国际米兰","createYear":"1908"}');
		console.log("保存key:"+"team");
	}
	function GetBrowserVersion()
{
    var Sys = {};
    var ua = navigator.userAgent.toLowerCase();
    window.ActiveXObject ? Sys.ie = ua.match(/msie ([\d.]+)/)[1] :
    document.getBoxObjectFor ? Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1] :
    window.MessageEvent && !document.getBoxObjectFor ? Sys.chrome = ua.match(/chrome\/([\d.]+)/)[1] :
    window.opera ? Sys.opera = ua.match(/opera.([\d.]+)/)[1] :
    window.openDatabase ? Sys.safari = ua.match(/version\/([\d.]+)/)[1] : 0;
    if(Sys.ie) return('IE: '+Sys.ie);
    if(Sys.firefox)return('FF:'+Sys.firefox);
    if(Sys.chrome) return('CH:'+Sys.chrome);
    if(Sys.opera) return('OP:'+Sys.opera);
    if(Sys.safari) return('SA:'+Sys.safari);
}
//   	console.log("浏览器版本:"+GetBrowserVersion());		

	console.log("是否支持本地localstorage:"+localStore.isSupportLocalStorage());		

   </script>
</html>
